package org.mysfit.ctp4j.core.service.impl;

import java.util.List;

import org.mysfit.ctp4j.infra.entity.FkData;
import org.mysfit.ctp4j.infra.entity.SkData;
import org.mysfit.ctp4j.infra.utils.TradeDataUtils;
import org.springframework.stereotype.Service;

/**
 * 
 * @author long.gf
 * @since 2022-12-06
 *
 */
@Service
public class PolyHelper {
	
	public int checkPolyAK(SkData sk) {
		String ftime = sk.getFtime();
		String fid = sk.getFid();
		String sec = ftime.substring(ftime.length()-2);
		double fp = sk.getFp().doubleValue();
		if("55".equals(sec)) {
			List<FkData> fkList = TradeDataUtils.LAST_FK_MAP.get(fid);
			if(!fkList.isEmpty()) {
				double pc = fkList.get(0).getPc().doubleValue();
				if(fp >= pc) {
					return 1;
				}else {
					return -1;
				}
			}
		}
		return 0;
	}
	
	public int checkPolyAP(SkData sk) {
		String ftime = sk.getFtime();
		String sec = ftime.substring(ftime.length()-2);
		if("15".equals(sec)) {
			return 1;
		}
		return 0;
	}
}	
